package utils
{
	/**
	 *  信息解析器
	 **/
	public class DeviceParser
	{
		private var locInfo:Object = null;
		
		public function DeviceParser(loc:Object)
		{
			locInfo = loc;
		}
		
		/**
		 * 获取速度
		 **/
		public function getSpeed():String
		{
			return new String(locInfo.speed*1.852);
		}
		
		/**
		 * 获取方向
		 **/
		public function getDirection():String
		{
			var value : int = int(locInfo.direction);
			if(value == 0)
			{
				return "正北";
			}else if(value > 0 && value < 90)
			{
				return "东北";
			}else if(value == 90)
			{
				return "正东";
			}else if(value > 90 && value < 180)
			{
				return "东南";
			}else if(value == 180)
			{
				return "正南";
			}else if(value > 180 && value < 270)
			{
				return "西南";
			}else if(value == 270)
			{
				return "正西";
			}else if(value > 270 && value < 360)
			{
				return "西北";
			}else if(value == 360)
			{
				return "正北";
			}else
			{
				return "未知";
			}
		}
		
		public function getLng():String
		{
			return locInfo.longitude;
		}
		
		public function getLat():String
		{
			return locInfo.latitude;
		}
		
		public function getAccState():String
		{
			if(locInfo.status_text.length >= 2)
			{
				var infoList:Object  = locInfo.status_text;
				return infoList[1];
			}
			return "";
		}
	}
}